%ifdef CONFIG
{
  "RegData": {
    "RAX": "0x00000000C5727F5A",
    "RBX": "0x00000000FAC690D7",
    "RCX": "0x000000002AAF1F77",
    "RDX": "0x00000000ADBE9F64",
    "RSI": "0x00000000ADBE9F64",
    "RDI": "0x00000000ADBE9F64"
  },
  "HostFeatures": ["SSE4.2"]
}
%endif

; This is a clone of the F2_F1 crc32 test with manually coded crc32 with prefix 66 instead of F2
; This can't user operand size override on 32-bit instructions for testing since it WILL override to 16-bit
mov rax, 0
mov rbx, 0
mov rcx, 0

mov rdx, 0
mov rsi, 0
mov rdi, 0

mov rbp, 0
lea rsp, [rel .data]

; crc32 eax, word [rel .data]
db 0x66 ; Operand size override
db 0xf2 ; Prefix
db 0x0f, 0x38, 0xf1, 0x05
dd 0x0000006c

; crc32 ebx, dword [rel .data + 2]
db 0xf2 ; Prefix
db 0x0f, 0x38, 0xf1, 0x1d,
dd 0x00000065

; crc32 rcx, qword [rel .data + 8]
db 0x66 ; Operand size override
db 0xf2 ; Prefix
db 0x48, 0x0f, 0x38, 0xf1, 0x0d,
dd 0x00000060

mov rbp, 0
.again16:
cmp rbp, 128
je .done16
; crc32 edx, word [rsp + rbp * 2]
db 0x66 ; Operand size override
db 0xf2 ; Prefix
db 0x0f, 0x38, 0xf1, 0x14, 0x6c

add rbp, 1
jmp .again16
.done16:

mov rbp, 0
.again32:
cmp rbp, 64
je .done32
; crc32 esi, dword [rsp + rbp * 4]
db 0xf2 ; Prefix
db 0x0f, 0x38, 0xf1, 0x34, 0xac

add rbp, 1
jmp .again32
.done32:

mov rbp, 0
.again64:
cmp rbp, 32
je .done64
; crc32 rdi, qword [rsp + rbp * 8]
db 0x66 ; Operand size override
db 0xf2 ; Prefix
db 0x48, 0x0f, 0x38, 0xf1, 0x3c, 0xec

add rbp, 1
jmp .again64
.done64:

hlt

align 16
; 256bytes of random data
.data:
db 0xe0, 0xfc, 0x2b, 0xa1, 0x06, 0x4f, 0x6c, 0xa7, 0x0f, 0x06, 0x6a, 0x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